package me.zhengjie.modules.transformer.query.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import me.zhengjie.modules.transformer.domain.FdsData;
import me.zhengjie.modules.transformer.query.mapper.MessageMapper;

import me.zhengjie.modules.transformer.query.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * FdsDataServiceImpl
 *
 * @author weiruitao
 * @date 2021/12/1
 */
@Service
public class MessageServiceImpl implements MessageService {

    @Autowired
    private MessageMapper messageMapper;

    @Override
    public List<String> queryField(String field,Integer recordid) {
        QueryWrapper<FdsData> queryWrapper = new QueryWrapper<>();
        queryWrapper.select(field).eq("record_id",recordid);
        List<FdsData> fdsData = messageMapper.selectList(queryWrapper);
        List<String> message = new ArrayList<>();
        for (FdsData fdsDatum : fdsData) {
            if(field.equals("tan_delta")) message.add(fdsDatum.getTanDelta());
            if(field.equals("e_real")) message.add(fdsDatum.getEReal());
            if(field.equals("e_imaginary")) message.add(fdsDatum.getEImaginary());
            if(field.equals("c_real")) message.add(fdsDatum.getCReal());
            if(field.equals("c_imaginary")) message.add(fdsDatum.getCImaginary());
        }
        return message;
    }
}
